package com.epam.training.concurrency.first.task1;

/**
 * 
 * @author Bogdan
 *
 */
public class NewThread implements Runnable {

	Thread t;
	private int secondLimit;
	private double sum;
	public static final double STEP = 0.0001;

	@Override
	public void run() {
		sum = 0.0;

		for (double i = 0; i < secondLimit; i += STEP) {
			sum += Math.sin(i) * Math.cos(i) - Math.sin(i) * Math.cos(i);
		}
	}

	NewThread() {
		t = new Thread(this);
	}

	NewThread(int limitTwo) {
		this();
		secondLimit = limitTwo;
	}

	public void call() {
		t.start();
	}

	public double getSum() {
		return sum;
	}

	public int getSecondLimit() {
		return secondLimit;
	}

	public void setSecondLimit(int secondLimit) {
		this.secondLimit = secondLimit;
	}

	public Thread getThread() {
		return t;
	}
}
